import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { NameVO, NameForm, NameQuery,NameTreeVO,FamilyNameTreeVO } from '@/api/genealogy/name/types';

/**
 * 查询世代名称列表
 * @param query
 * @returns {*}
 */

export const listName = (query?: NameQuery): AxiosPromise<NameVO[]> => {
  return request({
    url: '/genealogy/name/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询世代名称详细
 * @param id
 */
export const getName = (id: string | number): AxiosPromise<NameVO> => {
  return request({
    url: '/genealogy/name/' + id,
    method: 'get'
  });
};

/**
 * 新增世代名称
 * @param data
 */
export const addName = (data: NameForm) => {
  return request({
    url: '/genealogy/name',
    method: 'post',
    data: data
  });
};

/**
 * 修改世代名称
 * @param data
 */
export const updateName = (data: NameForm) => {
  return request({
    url: '/genealogy/name',
    method: 'put',
    data: data
  });
};

/**
 * 删除世代名称
 * @param id
 */
export const delName = (id: string | number | Array<string | number>) => {
  return request({
    url: '/genealogy/name/' + id,
    method: 'delete'
  });
};

/**
 * 查询族员数据结构
 */
export const getNameTree = (data:NameQuery): AxiosPromise<NameTreeVO[]> => {
  return request({
    url: '/genealogy/name/genealogyNameTree',
    method: 'post',
    data:data
  });
};

/**
 * 查询family tree族员数据结构
 */
export const getFamilyTree = (data:NameQuery): AxiosPromise<FamilyNameTreeVO[]> => {
  return request({
    url: '/genealogy/name/nameTreeList',
    method: 'post',
    data:data
  });
};
